GWTをGradleでビルドする GWT build with Gradle


概要

gradleでのビルド設定など



github

https://github.com/sassembla/GWTandGAEandGradle_SampleProject



Screencast

http://www.screenr.com/YBH8

*Gradleのスクリプトは下記のスクリプトをコピペしてるだけです!

試行錯誤をお見せ出来ずすいません。



手順

スクリーンショット 2012-03-11 18.57.10.png


build.gradle

apply plugin:"war"
apply plugin:"java"
modulename = "GWTandGAEandGradle_SampleProject"
version = 1.0


repositories {
	mavenCentral()
}
configurations { 
	gwtCompile 
}
dependencies {
	println("dependencies start")
	//gwt from maven repo, or local.
	compile "com.google.gwt:gwt-servlet:2.4.0"
    //gwt compiler
	gwtCompile (          
		[group: 'com.google.gwt', name: 'gwt-user', version: '2.4.0'],          
		[group: 'com.google.gwt', name: 'gwt-dev', version: '2.4.0']          
	)
	println("dependencies over")
}


//出力先をwarファイルに
gwtBuildDir = 'war'


task gwtCompile << {
	created = (new File(gwtBuildDir)).mkdirs()
	println "gwtBuildDir	"+gwtBuildDir
	ant.java(classname:'com.google.gwt.dev.Compiler', failOnError: 'true', fork: 'true') 
	{    
		//args settings
		jvmarg(value: '-Xmx512M')    
		arg(line: '-war ' + gwtBuildDir)
		arg(line: '-logLevel INFO')    
		arg(line: '-style PRETTY')
		println "start,,," + gwtBuildDir
		println "configurations.compile.asPath	"+configurations.compile.asPath
		arg(value: 'com.kissaki.'+modulename)
		classpath {      
			pathElement(location: 'src')      
			pathElement(path: configurations.compile.asPath)      
			pathElement(path: configurations.gwtCompile.asPath)    
		}  
	}
}


//dependency add.
war.dependsOn gwtCompile
war {
	println("war start")
    archiveName = "${modulename}.${extension}"
    from gwtBuildDir 
    manifest {
       	attributes 'Implementation-Title': modulename+' Version'
        attributes 'Implementation-Version': version
        attributes provider: 'gradle'
    }
	println("war over")
}